#include "agressform.h"
#include "ui_agressform.h"
#include <QTimer>

AgressForm::AgressForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AgressForm)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setWindowTitle("协议守则");
    ui->pushButton->setText(QString("同意(%1s)").arg(--this->agreeNum));
    //同意倒计时
    ui->pushButton->setDisabled(true);
    QTimer *agree=new QTimer(this);
    //每秒执行一次
    agree->start(1000);
    //定时器具体任务
    connect(agree,&QTimer::timeout,[this,agree](){
        ui->pushButton->setText(QString("同意(%1s)").arg(--this->agreeNum));
        if(this->agreeNum==0)
        {
            agree->stop();
            ui->pushButton->setText(QString("同意"));
            ui->pushButton->setDisabled(false);
        }
    });
    connect(ui->pushButton,&QPushButton::clicked,[this](){
        this->close();
    });
}

AgressForm::~AgressForm()
{
    delete ui;
}
